/*
 * httpnetworkmedium.h
 *
 *  Created on: Aug 28, 2011
 *      Author: anonovermind <anonovermind@gmail.com>
 */

#ifndef HTTPNETWORKMEDIUM_H_
#define HTTPNETWORKMEDIUM_H_

#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <memory>
#include "networkmedium.h"
#include "httpnetworkcontext.h"
#include "httpcachingresolver.h"

namespace Wishmaster2 {
namespace Network {

class HttpNetworkMedium : public NetworkMedium
{
public:
	HttpNetworkMedium();
	virtual ~HttpNetworkMedium();

	virtual const std::string protocol() const;
	virtual RequestPtr createRequest(int id, const Url& url);

	virtual NetworkContextPtr context() const;

private:
	std::shared_ptr<boost::thread> m_eventThread;

	boost::asio::io_service m_service;
	HttpCachingResolver* m_resolver;
	boost::asio::io_service::work m_work;
	HttpNetworkContextPtr m_context;
};

} /* namespace Network */
} /* namespace Wishmaster2 */
#endif /* HTTPNETWORKMEDIUM_H_ */
